Published on

linux 安装 maven

Authors
  • avatar
    Name
    游戏人生
    Twitter

1、在指定目录下下载 maven

wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz

2、解压

tar -zxvf apache-maven-3.9.6-bin.tar.gz

3、解压完毕以后,新建一个repository仓库,用于存放Maven下载下来的jar包

mkdir repository

4、编辑settings.xml文件

vim settings.xml

5、设置 maven 仓库路径

  <localRepository>/maven/repository</localRepository>

6、配置为阿里云镜像地址

  <mirror>
    <id>nexus-aliyun</id>
    <mirrorOf>*</mirrorOf>
    <name>Nexus aliyun</name>
    <url>https://maven.aliyun.com/repository/public</url>
  </mirror>

7、配置环境变量

  // 编辑profile文件
  vim /etc/profile

  // 添加环境变量
  export MAVEN_HOME=/maven/apache-maven-3.8.8export PATH=$PATH:$MAVEN_HOME/bin

  // 执行以下命令使profile文件生效 
  source /etc/profile